home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Applications
/
Audio
/
Patchmix
/
Source
/
Out.m
< prev
next >
Wrap
Text File
|
1992-07-31
|
2KB
|
126 lines
/* Generated by Interface Builder */
#import "Out.h"
#import "Instrum.h"
#import "Statement.h"
@implementation Out
+ initialize
{
image = [NXImage findImageNamed:"Out"];
outOffset.x = 25;
outOffset.y = 50;
return self;
}
- init
{
written = NO;
size.width = 80.;
size.height = 80.;
center.x = size.width/2.;
center.y = size.height/2.;
strcpy(type,"Out");
out = [[Param alloc] init:self :&outOffset];
[out setTitle:"Out:"];
paramList = [[List alloc] initCount:1];
[paramList addObject:out];
[Inst putUgenInList:self];
return self;
}
- remove
{
id cp,param;
int i;
// make sure not connected first
for(i = 0; i < ([paramList count]); i++) {
param = [paramList objectAt:i];
if(cp = [param getConnectedParam])
return 0;
}
// remove ugen from list
[Inst removeUgenFromList:self];
return self;
}
- (NXImage *)getImage
{
return image;
}
- move:(NXPoint *)newloc
{
location = *newloc;
[out move:&location];
return self;
}
- findParamAtPoint:(NXPoint *)point
{
NXRect *rect;
int i;
id param;
for(i = 0; i < [paramList count]; i++) {
param = [paramList objectAt:i];
rect = [param getRect];
if(NXMouseInRect(point,rect,NO))
return param;
}
//printf("no param found\n");
return nil;
}
- findCornerUgen
{
id par = nil;
id nupar = nil;
//printf("%s\n",type);
par = [paramList objectAt:0];
if(nupar = [par getConnectedParam]) // if there is an upper
[[nupar getUgen] findCornerUgen]; // left ugen, continue looking
else
return self;
}
- writeUgen
{
int i;
id param;
id ug;
id nupar;
char str[50];
int parent;
//printf("writing out %d\n",index);
sprintf(str,"\tfloat ug%d;\n",index);
[Inst putVarInList:str];
for(i = 0; i < [paramList count]; i++) {
param = [paramList objectAt:i];
if(nupar = [param getConnectedParam]) {
ug = [nupar getUgen];
if([ug getWritten] == NO)
parent = [[ug writeUgen] getIndex];
}
}
sprintf(str, "\t\tout[0] = ug%d;\n",parent);
[Inst putLoopInList:str];
sprintf(str,"\t\tif (chans > 1) {\n");
[Inst putLoopInList:str];
sprintf(str,"\t\t\tout[1] = out[0];\n\t\t}\n");
[Inst putLoopInList:str];
return self;
}
@end